/// 聊天消息类型
enum ChatMessageType {
  text,    // 文本消息
  image,   // 图片消息
  location // 位置消息
}

/// 聊天消息
class ChatMessage {
  final String id;
  final String content;
  final String time;
  final bool isSender;
  final ChatMessageType type;
  final MessageStatus status;
  final String? imageUrl;
  final Map<String, dynamic>? location;
  final String? avatar;

  const ChatMessage({
    required this.id,
    required this.content,
    required this.time,
    required this.isSender,
    this.type = ChatMessageType.text,
    this.status = MessageStatus.sent,
    this.imageUrl,
    this.location,
    this.avatar,
  });

  /// 创建一个新的 ChatMessage 实例，但可以更新部分属性
  ChatMessage copyWith({
    String? id,
    String? content,
    String? time,
    bool? isSender,
    ChatMessageType? type,
    MessageStatus? status,
    String? imageUrl,
    Map<String, dynamic>? location,
    String? avatar,
  }) {
    return ChatMessage(
      id: id ?? this.id,
      content: content ?? this.content,
      time: time ?? this.time,
      isSender: isSender ?? this.isSender,
      type: type ?? this.type,
      status: status ?? this.status,
      imageUrl: imageUrl ?? this.imageUrl,
      location: location ?? this.location,
      avatar: avatar ?? this.avatar,
    );
  }
}

/// 消息状态
enum MessageStatus {
  sending,  // 发送中
  sent,     // 已发送
  failed,   // 发送失败
  read      // 已读
} 